package com.weirdor.wxchat.www.web;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.weirdor.wxchat.module.entity.QywxAutoresponseDefault;
import com.weirdor.wxchat.module.entity.SysUser;
import com.weirdor.wxchat.module.service.IQywxAutoresponseDefaultService;
import com.weirdor.wxchat.support.constant.Constant;
import com.weirdor.wxchat.support.utils.R;
import com.xiaoleilu.hutool.convert.Convert;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * 默认关键字回复
 *
 * @author weirdor
 * @email 17996422@qq.com
 * @date 2017-12-03 02:27:00
 */
@RestController
@RequestMapping("/wxchat/qywxautoresponsedefault")
public class QywxAutoresponseDefaultController {
    @Autowired
    private IQywxAutoresponseDefaultService qywxAutoresponseDefaultService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("wxchat:qywxautoresponsedefault:list")
    public R list(@RequestParam Map<String, Object> params){
        EntityWrapper<QywxAutoresponseDefault> wrapper = new EntityWrapper<QywxAutoresponseDefault>();

        Page<QywxAutoresponseDefault> pageUtil=qywxAutoresponseDefaultService.selectPage(new Page<QywxAutoresponseDefault>(Convert.toInt(params.get("page")),Convert.toInt(params.get("limit"))),wrapper);
        return R.ok().put("page", pageUtil);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("wxchat:qywxautoresponsedefault:info")
    public R info(@PathVariable("id") String id){
        QywxAutoresponseDefault qywxAutoresponseDefault = qywxAutoresponseDefaultService.selectById(id);

        return R.ok().put("qywxAutoresponseDefault", qywxAutoresponseDefault);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("wxchat:qywxautoresponsedefault:save")
    public R save(@RequestBody QywxAutoresponseDefault qywxAutoresponseDefault){
        qywxAutoresponseDefaultService.insert(qywxAutoresponseDefault);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("wxchat:qywxautoresponsedefault:update")
    public R update(@RequestBody QywxAutoresponseDefault qywxAutoresponseDefault){
        qywxAutoresponseDefaultService.updateById(qywxAutoresponseDefault);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("wxchat:qywxautoresponsedefault:delete")
    public R delete(@RequestBody String[] ids){
        EntityWrapper<QywxAutoresponseDefault> entityWrapper=new EntityWrapper<>();
        entityWrapper.in("id",ids);
        qywxAutoresponseDefaultService.delete(entityWrapper);

        return R.ok();
    }

}

